/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.simpleLibrary;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author vramik
 */
public class BookManagerImpl implements BookManager {

    List<Book> books = new LinkedList<Book>();
    
    @Override
    public void addBook(Book book) {
        books.add(book);
    }

    @Override
    public void removeBook(Book book) {
        books.remove(book);
    }

    @Override
    public List<Book> findAllBooks() {
        return Collections.unmodifiableList(books);
    }

    @Override
    public Book findBookById(Long id) {
        Book wantedBook = null;
        for (Book book : books) {
            if (book.getId() == id) {
                wantedBook = book;
            }
        }
        return wantedBook;
    }

    @Override
    public void updateBook(Book book) {
        books.remove(book);
        books.add(book);
    }
    
}
